package com.cykj.v_m_sprintboot.tool;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class GetTime {
	public static String getTime() {
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"+" "+"HH:mm:ss");
		Date date =new Date();
		return format.format(date);
	}
	public static String getDate(){
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
		Date date =new Date();
		return format.format(date);
	}

	public static String dateToWeek(String datetime) {
		SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
		String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
		Calendar cal = Calendar.getInstance(); // 获得一个日历
		Date datet = null;
		try {
			datet = f.parse(datetime);
			cal.setTime(datet);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 指示一个星期中的某天。
		if (w < 0) {
			w = 0;
		}
		return weekDays[w];
	}
	public static String GetDayOfWeekOfMonth(String data){
		String f=data.substring((data.lastIndexOf("-")+1),(data.length()-1));
		Calendar cal = Calendar.getInstance(); // 获得一个日历
		cal.set(Calendar.DAY_OF_WEEK,Integer.valueOf(f));
		int week=cal.get(Calendar.DAY_OF_WEEK);
		return "当月第"+week+"周";
	};


}
